﻿using System;
using Mockery.Core.CommonContainer;
using Rhino.Mocks;

namespace Mockery.Core
{
    public class DeclarativeMockeryStateEvents<TTarget> : MockeryStateEvents
    {
        public Action<TTarget> ActionDelegate;

        private ICommonContainerBuilder _commonContainerBuilder;

        public DeclarativeMockeryStateEvents(MockRepository mockRepository, ICommonContainerBuilder commonContainerBuilder, IDisposableContextState disposableContextState)
            : base(mockRepository, disposableContextState)
        {
            _commonContainerBuilder = commonContainerBuilder;
        }

        public override void OnFirstAssert()
        {
            base.OnFirstAct();

            ActionDelegate(_commonContainerBuilder.ServiceLocator.GetInstance<TTarget>());
            
            base.OnFirstAssert();
        }

    }
}
